package com.xxxx.seckill.controller;


import com.xxxx.seckill.pojo.User;
//import com.xxxx.seckill.rabbitmq.MQSender;
import com.xxxx.seckill.service.IUserService;
import com.xxxx.seckill.vo.LoginVo;
import com.xxxx.seckill.vo.RespBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * <p>
 * 前端控制器
 * </p>
 * <p>
 */
@Controller
@RequestMapping("/user")
public class UserController {
	@Autowired
	private IUserService userService;

	@GetMapping("/hello")
	public String hello() {
		return "hello";
	}

	@RequestMapping("/toLogin")
	public String toLogin() {
		return "login";
	}

	@RequestMapping("/doLogin")
	@ResponseBody
	public RespBean doLogin(LoginVo loginVo, HttpServletRequest request, HttpServletResponse response) {
		return userService.doLogin(loginVo,request, response);
	}

	@RequestMapping("/info")
	@ResponseBody
	public RespBean userInfo(User user) {
		return RespBean.success(user);
	}

}
